import Toast from 'react-native-root-toast';

//Toast的统一在这里写
toast = null;

export const show = (message) => {
    this.toast && this.toast.destroy();
    // this.setState({
    //     toastMessage: message
    // });
    this.toast = Toast.show(message, {
        duration: Toast.durations.SHORT,
        position: Toast.positions.CENTER,
        // shadow: false,
        animation: true,
        hideOnPress: true,
        delay: 0,
        backgroundColor: 'rgba(0,0,0,0.7)',
        // shadowColor: false,
        textColor: '#fff',
        onPress: () => {
            // alert('You clicked me!')
        },
        onHidden: () => {
            this.toast.destroy();
            this.toast = null;
        }
    });
};

export const showBottom = (message) => {
    this.toast && this.toast.destroy();
    // this.setState({
    //     toastMessage: message
    // });
    this.toast = Toast.show(message, {
        duration: Toast.durations.SHORT,
        position: Toast.positions.BOTTOM,
        // shadow: false,
        animation: true,
        hideOnPress: true,
        delay: 0,
        backgroundColor: 'rgba(0,0,0,0.7)',
        // shadowColor: false,
        textColor: '#fff',
        onPress: () => {
            // alert('You clicked me!')
        },
        onHidden: () => {
            this.toast.destroy();
            this.toast = null;
        }
    });
};